<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <script src="/static/layui/layui.js" charset="utf-8"></script>
    <script src="/static/layui/ycTools.js" charset="utf-8"></script>
    <script src="/static/layui/ycNoImportents.js" charset="utf-8"></script>
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <!--依据各级供电单位的不同类别、型号、批次的计量设备，分析展示计量设备在不同状态时的单个设备停留时间-->
<body>
<table class="layui-hide" id="testTwo" lay-filter="testTwo"></table>
<script th:inline="javascript">
    var $,table;
    var depart_id=[[${depart_id ne null ?depart_id :''}]];
//    console.log(depart_id);
    layui.use('table', function(){

        table = layui.table;
        $ = layui.jquery;
        table.render({
            elem: '#testTwo'
            ,url:"/devices/devicesStateDepTab?depart_id="+depart_id
            ,toolbar: '#toolbarDemo'
            ,title: '单个设备数据表'
            ,height: 'full-20' //高度最大化减去差值
            ,totalRow: true
            ,parseData: function(res){ //res 即为原始返回的数据
                var dataHandleOne=[];

                dataHandleOne= singleDevDetailTab_dataHandle_ycNI(res.rows);
                return { //参考response的定义
                    "code": res.currentPage, //解析接口状态
                    "msg":  res.pageSize, //解析提示文本
                    "total": dataHandleOne.length, //解析数据长度
                    "rows": dataHandleOne //解析数据列表
                };
            }
            ,cols: [
                [
                {type: 'numbers', fixed: 'left', rowspan: 2}
                ,{field:'id', title: 'ID', width:10,hide:true, rowspan: 2}
                //,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计'}
                ,{field:'id', title:'设备列表( '+depart_id+' )' , rowspan: 2,templet: function(d){
                    console.log();
                    return "设备 "+d.LAY_INDEX;
                }}
                ,{field:'devices_name', title:'设备名称' , rowspan: 2}
                ,{field:'devices_model', title:'设备型号' , rowspan: 2}
                ,{field:'stateOutTime_detail', title:'平均停留时间',  rowspan: 2}
            ]
            ]
            ,response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                ,statusCode: 0 //规定成功的状态码，默认：0
                ,msgName: 'msg' //规定状态信息的字段名称，默认：msg
                ,countName: 'total' //规定数据总数的字段名称，默认：count
                ,dataName: 'rows' //规定数据列表的字段名称，默认：data
            }
            ,page: true
            ,limit:10
            ,limits:[5,10,20,30]
            ,id:'singleDevicesTable'
        });

        //监听行双击事件
        table.on('rowDouble(testTwo)', function(obj) {
            console.log(obj.data) //得到当前行数据
        });
    });
</script>

</body>
</html>